package com.econ.powercloud.ems.common.enums;

import java.util.Objects;

/**
 * @Author : zjf
 * @Description : 维度枚举
 * @Date : 2023/7/6 17:40
 * @Modified by : zjf
 */
public enum DimensionalType implements EnumMethod{
    ONE_DIMENSIONAL(1,"一维"),
    TWO_DIMENSIONAL(2,"二维"),;

    private Integer code;
    private String desc;

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    DimensionalType(int code, String desc){
        this.code=code;
        this.desc=desc;
    }

    public static DimensionalType fromCode(Integer code){
        for(DimensionalType type: DimensionalType.values()){
            if(Objects.equals(type.getCode(),code)){
                return type;
            }
        }
        return null;
    }

    public static Integer fromDesc(String desc){
        for(LocationUrl type: LocationUrl.values()){
            if(type.getDesc().equals(desc)){
                return type.getCode();
            }
        }
        return null;
    }
}
